<?php get_header(); ?>
<div class="span-24" id="contentwrap">
	<div class="span-16">
		<div id="content">

			<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
			<div class="post" id="post-<?php the_ID(); ?>">
				<h2 class="title">
					<?php 
					the_title();
					?>
				</h2>
				<div id="sous-menu">
				<?php 
					lng_page_children();
				?>
				</div>
				<div class="entry">
					<?php if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) { 
						the_post_thumbnail(array(300,225), array('class' => 'alignleft post_thumbnail'));
					} ?>
					<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>

					<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

				</div>
			</div>
			<?php endwhile; endif; ?>
			<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
			<?php function lng_page_children(){
				$my_wp_query = new WP_Query();
				$all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));
				$pagetitle = get_the_title();
				$mypage=get_page_by_title($pagetitle);
				$mypages = get_pages( array( 'child_of' => $mypage->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
				foreach ( $mypages as $page ) {
					$option = '><a href="' . get_page_link( $page->ID ) . '">';
					$option .= $page->post_title;
					$option .= '</a><br/>';
					echo $option;
				}
				}?>
		</div>
	</div>

	<?php get_sidebars(); ?>

</div>
<?php get_footer(); ?>